import axios from 'axios'

axios.defaults.headers.common['userToken'] = window.sessionStorage.getItem('token');

function $post(params) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'post',
            url: process.env.VUE_APP_BASE_API + params.api,
            data: params.params,
        }).then((response) => {
            resolve(response)
        }, (error) => {
            reject(error)
        })
    })
}

function $get(params) {
    return new Promise((resolve, reject) => {
        axios({
            method: 'get',
            url: process.env.VUE_APP_BASE_API + params.api,
            params: params.params
        }).then((response) => {
            resolve(response)
        }, (error) => {
            reject(error)
        })
    })
}


export {
    $get,
    $post
}